﻿////////////////////////////////////////////////////////////////////////////////
// Source Copyright (C) J.Fan
// @author      J.Fan
// @date        2013-01-19
// @revision    Revision in Version Control System
// @remark      
////////////////////////////////////////////////////////////////////////////////

namespace JsonConverter.Converter
{
    /// <summary>
    /// convert primitive type value as string to JSON.
    /// It convert uint, long, ulong, double and decimal to string type
    /// since JavaScript only in 32 bits precition.
    /// </summary>
    public class PrimitivePreciseConverter: PrimitiveConverter
    {
        public string Convert(object value)
        {
            switch (value.GetType().FullName)
            {
                case "System.UInt32":
                case "System.Int64":
                case "System.UInt64":
                case "System.Double":
                case "System.Decimal":
                    return StringConverter.ToJavascriptString(base.Convert(value));
                default:
                    return base.Convert(value);
            }
        }
    }
}
